<template>
  <div class="clear-cache">
    <el-dialog
      title="清除缓存"
      :visible.sync="clearCacheBoxVisible"
      width="70%"
      :close-on-click-modal="false"
      :show-close="false"
    >
      <div class="content">
          清除缓存会清除非加载表中的所有缓存，清除缓存后，再次加载对应的文件可能会很慢。
      </div>

      <span slot="footer" class="dialog-footer">
        <el-button @click="setClearCacheBoxVisible(false)">取 消</el-button>
        <el-button type="primary" @click="clearCache">清 除</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: ["clearCacheBoxVisible"],
  data() {
    return {};
  },
  methods:{
      setClearCacheBoxVisible(val){
          this.$emit('set-clear-cache-box-visible', val)
      },
      clearCache(){
          this.$axios.post('/clearCache')
          .then(res => {
              if(res.code == 200){
                  this.$message({
                      type: 'success',
                      message: res.msg,
                  })
                  
                  this.setClearCacheBoxVisible(false)
              }else this.$message.error(res.msg)
          })
      }
  }
};
</script>